//
//	 ______    ______    ______    
//	/\  __ \  /\  ___\  /\  ___\   
//	\ \  __<  \ \  __\_ \ \  __\_ 
//	 \ \_____\ \ \_____\ \ \_____\ 
//	  \/_____/  \/_____/  \/_____/ 
//
//	Powered by BeeFramework
//
//
//  MainBoard.m
//  Walker
//
//  Created by he chao on 3/10/14.
//    Copyright (c) 2014 leon. All rights reserved.
//

#import "MainBoard.h"

#import "ActivitiesBoard.h"
#import "MeetingBoard.h"
#import "ECircleBoard.h"
#import "UserCenterBoard.h"
#import "MessageRequest.h"

#pragma mark -
#define TAB_HEIGHT	50.0f


@implementation MainBoard
DEF_SINGLETON(MainBoard)

DEF_SIGNAL( TAB_0 )
DEF_SIGNAL( TAB_1 )
DEF_SIGNAL( TAB_2 )
DEF_SIGNAL( TAB_3 )
DEF_SIGNAL( TAB_4 )

- (void)load
{
	[super load];
}

- (void)unload
{
	[super unload];
}


#pragma mark Signal

ON_CREATE_VIEWS( signal )
{
    self.view.backgroundColor = [UIColor whiteColor];
    
    bee.ui.router[self.TAB_0] = [ActivitiesBoard class];
    bee.ui.router[self.TAB_1] = [MeetingBoard class];
    bee.ui.router[self.TAB_2] = [ECircleBoard class];
    bee.ui.router[self.TAB_3] = [UserCenterBoard class];
    //        bee.ui.router[self.TAB_4] = [PassportBoard class];
    
    [self.view addSubview:bee.ui.router.view];
    //[self.view addSubview:bee.ui.tabbar];
    tabbar = [[AppTabbar_iPhone alloc] init];
    [self.view addSubview:tabbar];
    
    [bee.ui.router open:self.TAB_0 animated:YES];
   
    
    
    tabbarOriginY = self.viewBound.size.height - TAB_HEIGHT + 1;
    
    [MessageRequest sharedInstance];
}



- (void)showMainActivity{
    
    [tabbar selectTab0];
    [bee.ui.router open:MainBoard.TAB_0 animated:NO];
    

}
//-(void)viewWillDisappear:(BOOL)animated{
//
//    [tabbar selectTab0];
//    [bee.ui.router open:MainBoard.TAB_0 animated:NO];
//
//}





ON_DELETE_VIEWS( signal )
{
}

ON_LAYOUT_VIEWS( signal )
{
}

ON_WILL_APPEAR( signal )
{
    [self.navigationController setNavigationBarHidden:YES animated:YES];
    tabbar.frame = CGRectMake( 0, tabbarOriginY, self.viewBound.size.width, TAB_HEIGHT );
    //bee.ui.tabbar.frame = CGRectMake( 0, tabbarOriginY, self.viewBound.size.width, TAB_HEIGHT );
    bee.ui.router.view.frame = CGRectMake( 0, 0, self.viewBound.size.width, self.viewBound.size.height );
}

ON_DID_APPEAR( signal )
{
}

ON_WILL_DISAPPEAR( signal )
{
}

ON_DID_DISAPPEAR( signal )
{
}


ON_SIGNAL2( BeeUINavigationBar, signal )
{
	[super handleUISignal:signal];
	
	if ( [signal is:BeeUINavigationBar.LEFT_TOUCHED] )
	{
	}
	else if ( [signal is:BeeUINavigationBar.RIGHT_TOUCHED] )
	{
	}
}

ON_SIGNAL3( AppTabbar_iPhone, btn_tab0, signal )
{
    [tabbar selectTab0];
    //[bee.ui.tabbar selectTab0];
    [bee.ui.router open:MainBoard.TAB_0 animated:YES];
	//[bee.ui.tabbar selectHome];
	//[bee.ui.router open:AppBoard_iPhone.TAB_HOME animated:YES];
}

ON_SIGNAL3( AppTabbar_iPhone, btn_tab1, signal )
{
    [tabbar selectTab1];
    [bee.ui.router open:MainBoard.TAB_1 animated:YES];
//	[bee.ui.tabbar selectSearch];
//	[bee.ui.router open:AppBoard_iPhone.TAB_SEARCH animated:YES];
}

ON_SIGNAL3( AppTabbar_iPhone, btn_tab2, signal )
{
    [tabbar selectTab2];
    [bee.ui.router open:MainBoard.TAB_2 animated:YES];
    //	[bee.ui.tabbar selectSearch];
    //	[bee.ui.router open:AppBoard_iPhone.TAB_SEARCH animated:YES];
}

ON_SIGNAL3( AppTabbar_iPhone, btn_tab3, signal )
{
    [tabbar selectTab3];
    [bee.ui.router open:MainBoard.TAB_3 animated:YES];
    //	[bee.ui.tabbar selectSearch];
    //	[bee.ui.router open:AppBoard_iPhone.TAB_SEARCH animated:YES];
}


- (void)selectIndexPage:(int)index{
    switch (index) {
        case 0:
        {
            [tabbar selectTab0];
            [bee.ui.router open:MainBoard.TAB_0 animated:NO];
        }
            break;
        case 1:
        {
            [tabbar selectTab1];
            [bee.ui.router open:MainBoard.TAB_1 animated:NO];
        }
            break;
        case 2:
        {
            [tabbar selectTab2];
            [bee.ui.router open:MainBoard.TAB_2 animated:NO];
        }
            break;
        case 3:
        {
            [tabbar selectTab3];
            [bee.ui.router open:MainBoard.TAB_3 animated:NO];
        }
            break;
            
        default:
            break;
    }
}

@end
